#include"comment.h"

int main()
{
   
  key_t key = ftok(PATH_NAME,PROJ_ID);
  if(key < 0){
    perror("ftok");
    return 1;
  }
  int shmid = shmget(key, MEMORY_SIZE, IPC_CREAT);
  if(shmid < 0)
  {
    perror("shmget");
    return 1;
  }
  char* mem = (char*)shmat(shmid,NULL,0);
  printf("write process attaches success!\n");
  sleep(5);
  char c = 'A';
  while(c <= 'J'){
    mem[c-'A'] = c;
    c++;
    mem[c-'A'] = '\0';
    sleep(1);
  }

  shmdt(mem);
  sleep(2);
  printf("write process detaches success!\n");

  //write端不需要关心共享内存的删除
  return 0;
}
